﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HRM.Entity;
using System.Data;
using SubSonic.Schema;

namespace HRM.DAL
{
    public class EmployeeDAL: BaseDAL
    {
        public Employee Add(Employee emp)
        {
            Repository.Add<Employee>(emp);
            return emp;
        }

        public List<Employee> GetAll()
        {
            return Repository.All<Employee>().ToList();
        }

        public Employee GetByID(int ID)
        {
            return Repository.Single<Employee>(emp => emp.ID == ID);
        }

        public Employee GetByEmpID(string empID)
        {
            return Repository.Single<Employee>(emp => emp.EmpID == empID);
        }

        public Employee Update(Employee emp)
        {
            Repository.Update<Employee>(emp);
            return emp;
        }

        public DataSet GetEmployees()
        {
            StoredProcedure sp = GetStoreProc("spGetEmployees");
            return sp.ExecuteDataSet();
        }

        public DataSet GetByID(string empID)
        {
            StoredProcedure sp = GetStoreProc("spGetEmployeeByEmpID");
            sp.Command.AddParameter("@EmpID", empID, DbType.String);
            return sp.ExecuteDataSet();
        }
    }
}
